<?php
/**
 * Each engineer has a duty to keep the code elegant
 * Created by wolffy.
 * Author @wolffy<13750088090@sina.cn>
 * Date: 2018/8/6
 * Time: 14:40
 */
namespace App\Http\Controllers\Api\Jobs;

use App\Http\Controllers\Controller;
use App\Services\RedisService;
use App\Services\RepaymentPlanJobsService;
use Illuminate\Http\Request;

class RepaymentPlanJobsController extends Controller
{
    protected $repaymentPlanJobsService;

    public function __construct(RepaymentPlanJobsService $repaymentPlanJobsService)
    {
        $this->repaymentPlanJobsService = $repaymentPlanJobsService;
    }

    /**
     * 消费任务
     */
    public function consume()
    {
        $this->repaymentPlanJobsService->consumeJobs();
    }

    /**
     * 还款任务
     */
    public function repayment()
    {
        $this->repaymentPlanJobsService->repaymentJobs();
    }

    /**
     * 还款失败自动提现
     */
    public function repaymentPlanAutoWithdraw()
    {
        $this->repaymentPlanJobsService->repaymentPlanAutoWithdrawJobs();
    }

    public function repaymentPlanActionWithdraw(Request $request)
    {
        $passageId = $request->passage_id;
        $userId = $request->user_id;
        $repaymentPlanId = $request->plan_id;
        $planRepaymentId = $request->repayment_plan_id;
        $this->repaymentPlanJobsService->intoRepaymentAutoWithdrawJobs($passageId, $userId,
            $repaymentPlanId, $planRepaymentId);
    }
}